import Ember from 'ember';
import config from 'game-front/config/environment';

export default Ember.Route.extend({
	share:Ember.inject.service(),
	model(params) {
		var share = this.get("share");
		var userInfo = this.modelFor("application");
		var link = window.location.origin + config.baseURL + "sharegrade?"  + Ember.$.param($.extend(params, {key:userInfo.userId}));
		var shareLink = {
			title: '90秒夺宝-棒打疯猫-本次得分' + params.score, // 分享标题
			desc: `棒子轻轻一挥打了${params.score}分，求超越`,
			link: link + "#public=true", // 分享链接
			imgUrl: 'http://game.inkanke.com/yydb/assets/images/banner-62c08e1120ab2db597edb26e069052c5.png', // 分享图标
			success: function () {
				share.reward(userInfo.userId);
				// 生成推荐二维码
				share.createQR(userInfo.userId);
			},
			cancel: function () {
				// 用户取消分享后执行的回调函数
			}
		};
		share.config(shareLink);

		params.position = parseInt(params.position) + 1;
		return params;
	},
	beforeModel: function(posts, transition) {
		Ember.run.scheduleOnce('afterRender', this, function() {
			$(".ranking").height(document.body.scrollHeight);
		});
	},

	actions: {
		showShare() {
			$(".shade-share").css({"display": "block"});
		},
		hidder(){
			$(".shade-share").css({"display": "none"});
		}
	}
});
